﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Sol_Demo.Api.Models;
using Sol_Demo.Api.Service;

namespace Sol_Demo.Api.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class PT_ProblemTypeController : ControllerBase
    {
        IService service;
        public PT_ProblemTypeController(IService Service)
        {
            service = Service;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="param">param</param>
        /// <returns></returns>
        [HttpPost("Query")]
        public IActionResult Query([FromBody]PT_ProblemType param)
        {
            var result = service.Query(param);

            //List<object> data = new List<object>()
            //{
            //    new  { ID = 1,CPYW = "1", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 2,CPYW = "2", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 3,CPYW = "3", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 4,CPYW = "4", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 5,CPYW = "5", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 6,CPYW = "6", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 7,CPYW = "7", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 8,CPYW = "8", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 9,CPYW = "9", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 10,CPYW = "10", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 11,CPYW = "11", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 12,CPYW = "12", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 13,CPYW = "13", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 14,CPYW = "14", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 15,CPYW = "15", PROBLEMTYPE = 42,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 16,CPYW = "16", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 17,CPYW = "17", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 18,CPYW = "18", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 19,CPYW = "19", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 20,CPYW = "20", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 21,CPYW = "21", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID =22,CPYW = "22", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 23,CPYW = "23", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 24,CPYW = "24", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 25,CPYW = "25", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 26,CPYW = "26", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 27,CPYW = "27", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 28,CPYW = "28", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 29,CPYW = "29", PROBLEMTYPE = 32,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"},
            //    new  { ID = 30,CPYW = "30", PROBLEMTYPE = 42,PROBLEMTYPESUB="西湖区湖底公园1号",FLAWCode="西湖区湖底公园1号"}
            //};

            ResponseModel response = new ResponseModel()
            {
                RESULT = result != null ? true : false,
                MESSAGE = result != null ? "成功" : "失败",
                RESPONSE = result
            };

            return Ok(response);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="param">param</param>
        /// <returns></returns>
        [HttpPost("Delete")]
        public IActionResult Delete([FromBody]PT_ProblemType param)
        {
            var result = service.delete(param);

            ResponseModel response = new ResponseModel()
            {
                RESULT = result == 1 ? true : false,
                MESSAGE = result == 1 ? "成功" : "失败",
                RESPONSE = result
            };

            return Ok(response);
        }


        /// <summary>
        /// 新增/修改
        /// </summary>
        /// <param name="param">param</param>
        /// <returns></returns>
        [HttpPost("InsertorUpdate")]
        public IActionResult InsertorUpdate([FromBody]PT_ProblemType param)
        {
            var result = service.insertorupdate(param);

            ResponseModel response = new ResponseModel()
            {
                RESULT = result == 1 ? true : false,
                MESSAGE = result == 1 ? "成功" : "失败",
                RESPONSE = result
            };

            return Ok(response);
        }

    }
}